package 数据结构.树形结构;

public class RBTreeNode<T> implements Comparable<T> {
	private T value;
	private RBTreeNode<T> left;
	private RBTreeNode<T> right;
	private RBTreeNode<T> parent;
	private boolean red;

	@Override
	public int compareTo(T o) {
		return 0;
	}

	// constructor
	public RBTreeNode() {
	}

	// constructor
	public RBTreeNode(T value) {
		this.value = value;
	}

	// constructor
	public RBTreeNode(T value, boolean isRed) {
		this.value = value;
	}

	//getter and setter


	public T getValue() {
		return value;
	}

	public void setValue(T value) {
		this.value = value;
	}

	public RBTreeNode<T> getLeft() {
		return left;
	}

	public void setLeft(RBTreeNode<T> left) {
		this.left = left;
	}

	public RBTreeNode<T> getRight() {
		return right;
	}

	public void setRight(RBTreeNode<T> right) {
		this.right = right;
	}

	public RBTreeNode<T> getParent() {
		return parent;
	}

	public void setParent(RBTreeNode<T> parent) {
		this.parent = parent;
	}

	public boolean isRed() {
		return red;
	}

	public void makeRed() {
		this.red = true;
	}
	public void makeBlack() {
		this.red = false;
	}

	// 新增的
	public boolean isBlack() {
		return !red;
	}


	/**
	 * is leaf node
	 **/
	boolean isLeaf() {
		return left == null && right == null;
	}
}
